# -*- coding: utf-8 -*-
# @Time : 2023/12/1 19:53
# @Author : 支晓光
# @Email : 1473858993@qq.com
# @File : serch.py
# @Project : YouGuuUII
from time import sleep

from appium.webdriver.common.appiumby import AppiumBy

from common.base_page import BasePage


class Serch(BasePage):  # 封装Serch页面类，继承基类
    # 输入框
    et_stock_search = AppiumBy.ID,'com.jhss.youguu:id/et_stock_search'
    # 展示用户
    nickNameView = AppiumBy.ID,'com.jhss.youguu:id/nickNameView'
    # 抱歉
    tv_tips = AppiumBy.ID,'com.jhss.youguu:id/tv_tips'
    # 输入空
    tv_superman_title = AppiumBy.ID,'com.jhss.youguu:id/tv_superman_title'
    def serch(self,text):
        sleep(1)
        self.tap(676,167)
        self.send_keys(self.et_stock_search,text)
        if len(text) == 0:
            self.zero = self.find_element(self.tv_superman_title).text
        else:
            self.name = self.find_elements(self.nickNameView)
            if len(self.name)>0:
                self.status = 1
                self.namel = []
                for i in self.name:
                    self.namel.append(i.text)
                return self.namel
            else:
                self.status = 0
                self.no_serch = self.find_element(self.tv_tips).text
